Skip to content

C: Use hb_string_T when initializing new tokens#798

Merged
marcoroth merged 4 commits into
marcoroth:mainfrom
timkaechele:token-init-hb-string
Nov 8, 2025
Merged

C: Use hb_string_T when initializing new tokens#798
marcoroth merged 4 commits into
marcoroth:mainfrom
timkaechele:token-init-hb-string

Conversation

@timkaechele

@timkaechele timkaechele commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

This PR changes the signature of the token_init function to take hb_string_T instead of a raw string.

The token still stores its value as a char *. This PR just changes the interface for initializing tokens.

The call sites in the lexer are adapted to the new token_init signature and buffer usages are minimized.

Newly introduced functions

  • hb_string_range a function that allows to get a substring from a given string
  • hb_string_to_c_string_using_malloc a version of hb_string_to_c_string that doesn't rely on the arena allocator. (Necessary since we don't have widespread use of the arena allocator yet)

@marcoroth marcoroth left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @timkaechele! 🙏🏼

@marcoroth marcoroth merged commit d5a74c8 into marcoroth:main Nov 8, 2025
17 checks passed
marcoroth pushed a commit that referenced this pull request Nov 8, 2025
Based on the changes made in #798
this PR changes the remaining functions in the lexer to use
`hb_string_T`.
@timkaechele timkaechele deleted the token-init-hb-string branch November 8, 2025 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants